﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for UserControl2.xaml
    /// </summary>
    public partial class UIWBFK : ViewBase
    {
        public VWBFKOPF TMV
        {
            get
            {
                return (VWBFKOPF)MV;
            }
        }

        #region ==ERVER===========
        public static readonly DependencyProperty ERVERProperty = DependencyProperty.Register("ERVER",
            typeof(int), typeof(UIWBFK),
            new FrameworkPropertyMetadata(1, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnERVERChanged));
        public int ERVER
        {
            get
            {
                return (int)GetValue(ERVERProperty);
            }
            set
            {
                SetValue(ERVERProperty, value);
                OnERVERChg();
            }
        }

        private static void OnERVERChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWBFK;
            if (src != null)
            {
                src.ERVER = (int)e.NewValue;
            }
        }

        public virtual void OnERVERChg()
        {
        }

        #endregion   

        #region ==DFFSCHL===========
        public static readonly DependencyProperty DFFSCHLProperty = DependencyProperty.Register("DFFSCHL",
            typeof(string), typeof(UIWBFK),
            new FrameworkPropertyMetadata("   ", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnDFFSCHLChanged));
        public string DFFSCHL
        {
            get
            {
                return (string)GetValue(DFFSCHLProperty);
            }
            set
            {
                SetValue(DFFSCHLProperty, value);
                OnDFFSCHLChg();
            }
        }

        private static void OnDFFSCHLChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWBFK;
            if (src != null)
            {
                src.DFFSCHL = (string)e.NewValue;
            }
        }

        public virtual void OnDFFSCHLChg()
        {
        }

        #endregion

        #region ==RWAUF===========
        public static readonly DependencyProperty RWAUFProperty = DependencyProperty.Register("RWAUF",
            typeof(string), typeof(UIWBFK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnRWAUFChanged));
        public string RWAUF
        {
            get
            {
                return (string)GetValue(RWAUFProperty);
            }
            set
            {
                SetValue(RWAUFProperty, value);
                OnRWAUFChg();
            }
        }
        private static void OnRWAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWBFK;
            if (src != null)
            {
                src.RWAUF = (string)e.NewValue;
            }
        }
        public virtual void OnRWAUFChg()
        { }
        #endregion
        
        #region ==CMTR===========
        public static readonly DependencyProperty CMTRProperty = DependencyProperty.Register("CMTR",
            typeof(double), typeof(UIWBFK),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnCMTRChanged));
        public double CMTR
        {
            get
            {
                return (double)GetValue(CMTRProperty);
            }
            set
            {
                SetValue(CMTRProperty, value);
            }
        }
        private static void OnCMTRChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWBFK;
            if (src != null)
            {
                src.CMTR = (double)e.NewValue;
            }
        }
        #endregion
        public UIWBFK()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;  
        }
        public override void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if(dwMaster==null)
            {
                KEY = "";
            }
            else
            {
                KEY = TMV.WBFKRWKRS + TMV.WBFKRWLFD + TMV.WBFKRWPOS + TMV.WBFKVERSION;
                
            }
        } 
    }
}
